
package com.eb.bi.common.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Properties;
/**
 * ���?�����Ĺ����࣬���Դ���windows��linux��ϵͳ
 * @author fanwen
 *
 */
public class ENVProcessor {
	public Properties getEnv() throws Exception {
		Properties prop = new Properties();
		String OS = System.getProperty("os.name").toLowerCase();
		//System.out.println("����ϵͳ:" + OS);
		Process p = null;
		if (OS.indexOf("windows") > -1) {
			p = Runtime.getRuntime().exec("cmd /c set");
		}
		if (OS.indexOf("linux") > -1) {
			p = Runtime.getRuntime().exec("sh -c set");
		}
		BufferedReader br = new BufferedReader(new InputStreamReader(p
				.getInputStream()));
		String line;
		while ((line = br.readLine()) != null) {
			int i = line.indexOf("=");
			if (i > -1) {
				String key = line.substring(0, i);
				String value = line.substring(i + 1);
				prop.setProperty(key, value);
			}
		}
		return prop;
	}

	public static void main(String[] args) {
		try {
			ENVProcessor sp = new ENVProcessor();
			Properties p = sp.getEnv();
			System.out.println(p.getProperty("IDOXDIR"));
		} catch (Exception e) {
			System.out.println(e);
		}
	}
}
